package com.cby.widget.sample.fragments

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.cby.widget.lib.clock.ClockView
import com.cby.widget.lib.kotlin.*

/**
 * @description: PathClockFragment
 *
 * @author ChenBaoyang
 * @date 2021/10/8 14:50
 */
class PathClockFragment : Fragment() {

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return ConstraintLayout {
            layout_width = match_parent
            layout_height = match_parent

            val clockView = ClockView(context).apply {
                layout_id = "cv"
                layout_width = 300
                layout_height = 300
                center_horizontal = true
                center_vertical = true
                addView(this)
                background_color = "#f9f9f9"
            }

            TextView {
                layout_width = wrap_content
                layout_height = wrap_content
                textSize = 16f
                textColor ="#3F4658"
                gravity = gravity_center
                top_toBottomOf = "cv"
                text = "start"
                center_horizontal = true
                onClick = {
                    clockView.start()
                }
            }
        }
    }
}